package newProject;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Date;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class GetWebResource {
    static Pattern pattern=Pattern.compile("\\d{11}");//匹配11位手机号
    static Pattern pattern1=Pattern.compile("[0-35-68-9]{11}");//不带4和7
    static Pattern pattern2=Pattern.compile("\\d*(\\d)\\1{2}\\d*?");//中间三A号码
    static Pattern pattern3=Pattern.compile("\\d{6}([0-9]0123|[^0]1234|[^1]2345|[^2]3456|[^3]4567|[^4]5678|[^5]6789)");//4连 ABCD 升
    static Pattern pattern4=Pattern.compile("\\d{5}(d{2})(?!1)(d{2})\\1" );//**ab**ab
    static Pattern pattern5=Pattern.compile("(\\d)\\1{2}$");//结尾双联 AA



    public static void main(){
         Matcher matcher,matcher1,matcher2,matcher3,matcher4,matcher5;
        while(true){
            Long strTime=new Date().getTime();
            //  System.out.println("时间戳:"+strTime);
            try {
                //建立链接
                URL url=new URL("https://msgo.10010.com/NumApp/NumberCenter/qryNum?callback=jsonp_queryMoreNums&provinceCode=51&cityCode=536&monthFeeLimit=0&goodsId=512112279603&searchCategory=3&net=01&amounts=200&codeTypeCode=&searchValue=&qryType=02&goodsNet=4&channel=msg-xsg&_="+strTime);
                HttpURLConnection httpurlconnection=(HttpURLConnection) url.openConnection();
                httpurlconnection.setDoInput(true);
                httpurlconnection.setRequestMethod("GET");
                httpurlconnection.setRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)");
                //获取输入流
                InputStream input=httpurlconnection.getInputStream();
                //把字节流按UTF-8 形式 转 字符流
                InputStreamReader read=new InputStreamReader(input,"UTF-8");
                //为好处理 把字符流 用 缓存流 处理
                BufferedReader br =new BufferedReader(read);
                String str=br.readLine();
                    matcher=pattern.matcher(str.substring(83,3483));
                    matcher1=pattern1.matcher(str.substring(83,3483));
                    matcher2=pattern2.matcher(str.substring(83,3483));
                    matcher3=pattern3.matcher(str.substring(83,3483));
                    matcher4=pattern4.matcher(str.substring(83,3483));
                    matcher5=pattern5.matcher(str.substring(83,3483));
                    while(matcher.find()){
                        if(matcher1.find()) {XJiangJFrame.setJTextareaContent1(matcher1.group());}
                        if(matcher2.find()) {XJiangJFrame.setJTextareaContent2(matcher2.group());}
                        if(matcher3.find()) {XJiangJFrame.setJTextareaContent3(matcher3.group());}
                        if(matcher4.find()) {XJiangJFrame.setJTextareaContent4(matcher4.group());}
                        if(matcher5.find()) {XJiangJFrame.setJTextareaContent5(matcher5.group());}
                        XJiangJFrame.setJTextareaContent(matcher.group());//把匹配的内容 输入到文本框

                    }


                //关闭资源
                br.close();
                read.close();
                input.close();
                httpurlconnection.disconnect();
            } catch (MalformedURLException e) {
                System.out.println("网页不存在");
            } catch (IOException e) {
                System.out.println("请求方式不对");
            }
        }
    }

}
